package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspSysOrg;

public class ErspSysOrgDao extends JActiveTable {
	public ErspSysOrgDao() {
		this.setDBTableName("ersp_sys_org");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());
		AddField(new JActiveField("org_name", "org_name", ActiveField.ftString, 200));
		AddField(new JActiveField("org_addr", "org_addr", ActiveField.ftString, 200));
		AddField(new JActiveField("org_desc", "org_desc", ActiveField.ftString, Integer.MAX_VALUE));
		AddField(new JActiveField("org_posx", "org_posx", ActiveField.ftDouble));
		AddField(new JActiveField("org_posy", "org_posy", ActiveField.ftDouble));
		AddField(new JActiveField("org_area", "org_area", ActiveField.ftInteger));
		AddField(new JActiveField("sys_path", "sys_path", ActiveField.ftString, 500));

		AddField(new JActiveField("create_time", "create_time", ActiveField.ftLong));
		setDefaultFieldValue("create_time", String.valueOf(DateUtils.getDayTimeNum()));

		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));
		setDbKeyFields("id");
	}

	public int add(ErspSysOrg vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("org_name", vo.getOrg_name());
		setFieldValue("org_addr", vo.getOrg_addr());
		setFieldValue("org_desc", vo.getOrg_desc());
		setFieldValue("org_posx", vo.getOrg_posx());
		setFieldValue("org_posy", vo.getOrg_posy());
		setFieldValue("org_area", vo.getOrg_area());
		setFieldValue("sys_path", vo.getSys_path());
		return DBManager.ExecSQL(this.getSQL());
	}

	public int save() {
		return DBManager.ExecSQL(this.getSQL());
	}

	public int del() {
		return DBManager.ExecSQL(this.getDeleteSQL());
	}
}
